package com.lty.spider.process;

import com.lty.spider.entity.Movie;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * create by  lty
 * on  2019-06-19  15:30
 */
public class MovieProcess implements PageProcessor {
    @Override
    public void process(Page page) {
        Movie movie = new Movie();
        movie.setTitle(page.getHtml().xpath("//*[@class='co_content8']/ul/table/tbody/tr/td/b/a/text()").all());
        movie.setLink(page.getHtml().xpath("//*[@class='co_content8']/ul/table/tbody/tr/td/b/a/@href").all());
        movie.setContent(page.getHtml().xpath("//*[@class='co_content8']/ul/table/tbody/tr[4]/td/text()").all());
        page.putField("movie",movie);
        /// TODO: 2019-06-19 设置sch https://www.dytt8.net/html/gndy/dyzz/list_23_2.html


        }

    private Site site = Site.me().setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36");


    @Override
    public Site getSite() {
        return site;
    }
}
